package com.ccys.app.controller;

import com.ccys.app.service.IndoPostConsultFlowService;
import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.dto.app.IndoPostConsultFlow.IndoCheckoutDto;
import com.ccys.db.dto.app.IndoPostConsultFlow.SetPaymentMethodDto;
import com.ccys.db.dto.app.IndoPostConsultFlow.SetShippingMethodDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author：XLY
 * @Date：2024/2/1 0001
 */
@RestController
@RequestMapping("/indoPostConsultFlow")
@Api(tags = "Indo Post Consult Flow")
public class IndoPostConsultFlowController {

    @Resource
    private IndoPostConsultFlowService indoPostConsultFlowService;

    @ApiOperation("Indo Post Consult Flow/1")
    @PostMapping("Checkout")
    @Transactional
    public ResponseResultApp checkout(@RequestBody IndoCheckoutDto dto) {

        return indoPostConsultFlowService.checkout(dto);
    }


    @ApiOperation("Indo Post Consult Flow/2")
    @PostMapping("SetShippingMethod")
    @Transactional
    public ResponseResultApp setShippingMethod(@RequestBody SetShippingMethodDto dto) {
        //TODO 与 Checkout 相似，也是计算结算业务
        return indoPostConsultFlowService.setShippingMethod(dto);
    }

    @ApiOperation("Indo Post Consult Flow/3")
    @GetMapping("GetPaymentMethods/{customerId}")
    public ResponseResultApp getPaymentMethods(@PathVariable String customerId) {
        return indoPostConsultFlowService.getPaymentMethods(customerId);
    }



    @ApiOperation("Indo Post Consult Flow/4")
    @PostMapping("SetPaymentMethod/{customerId}")
    @Transactional
    public ResponseResultApp setPaymentMethod(@PathVariable String customerId,@RequestBody SetPaymentMethodDto dto) {

         return indoPostConsultFlowService.setPaymentMethod(customerId,dto);
    }
}
